from sqlalchemy import Sequence, ForeignKey, Column
from sqlalchemy.types import Integer, String
from sqlalchemy.orm import relationship, backref
from __init__ import Base

class Widgets(Base):

    __tablename__ = "widgets"

    id = Column(Integer, Sequence('widget_id_seq'), primary_key=True)
    view = Column(String(10))
    location = Column(Integer(10))
    dashboardid = Column(Integer, ForeignKey('dashboards.id'))
    gridid = Column(Integer, ForeignKey("grids.id"))
    
    widgetgroup = relationship('WidgetGroup')
    columns = relationship('Columns')
    variables = relationship('Variables')

    def __init__(self, view, location, dashboardid, gridid):
        self.view = view
        self.location = location
        self.dashboardid = dashboardid
        self.gridid = gridid

    def __repr__(self):
        return "<Widgets('%s', '%s')>" % (self.view, self.location)
